home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / cpu / i8039 / i8039.h < prev   
C/C++ Source or Header  |  2000-05-18  |  9KB  |  247 lines

  1. /**************************************************************************
  2.  *                      Intel 8039 Portable Emulator                      *
  3.  *                                                                        *
  4.  *                   Copyright (C) 1997 by Mirko Buffoni                  *
  5.  *  Based on the original work (C) 1997 by Dan Boris, an 8048 emulator    *
  6.  *     You are not allowed to distribute this software commercially       *
  7.  *        Please, notify me, if you make any changes to this file         *
  8.  **************************************************************************/
  9.  
  10. #ifndef _I8039_H
  11. #define _I8039_H
  12.  
  13. #ifndef INLINE
  14. #define INLINE static inline
  15. #endif
  16.  
  17. #include "osd_cpu.h"
  18.  
  19. enum { I8039_PC=1, I8039_SP, I8039_PSW, I8039_A, I8039_IRQ_STATE,
  20.     I8039_R0, I8039_R1, I8039_R2, I8039_R3, I8039_R4, I8039_R5, I8039_R6, I8039_R7 };
  21.  
  22. extern int i8039_ICount;        /* T-state count                          */
  23.  
  24. /* HJB 01/05/99 changed to positive values to use pending_irq as a flag */
  25. #define I8039_IGNORE_INT    0   /* Ignore interrupt                     */
  26. #define I8039_EXT_INT        1    /* Execute a normal extern interrupt    */
  27. #define I8039_TIMER_INT     2    /* Execute a Timer interrupt            */
  28. #define I8039_COUNT_INT     4    /* Execute a Counter interrupt            */
  29.  
  30. extern void i8039_reset(void *param);            /* Reset processor & registers    */
  31. extern void i8039_exit(void);                    /* Shut down CPU emulation        */
  32. extern int i8039_execute(int cycles);            /* Execute cycles T-States - returns number of cycles actually run */
  33. extern unsigned i8039_get_context(void *dst);    /* Get registers                */
  34. extern void i8039_set_context(void *src);        /* Set registers                */
  35. extern unsigned i8039_get_pc(void);             /* Get program counter            */
  36. extern void i8039_set_pc(unsigned val);         /* Set program counter            */
  37. extern unsigned i8039_get_sp(void);             /* Get stack pointer            */
  38. extern void i8039_set_sp(unsigned val);         /* Set stack pointer            */
  39. extern unsigned i8039_get_reg(int regnum);        /* Get specific register      */
  40. extern void i8039_set_reg(int regnum, unsigned val);    /* Set specific register      */
  41. extern void i8039_set_nmi_line(int state);
  42. extern void i8039_set_irq_line(int irqline, int state);
  43. extern void i8039_set_irq_callback(int (*callback)(int irqline));
  44. extern const char *i8039_info(void *context, int regnum);
  45. extern unsigned i8039_dasm(char *buffer, unsigned pc);
  46.  
  47. /*   This handling of special I/O ports should be better for actual MAME
  48.  *   architecture.  (i.e., define access to ports { I8039_p1, I8039_p1, dkong_out_w })
  49.  */
  50.  
  51. #if OLDPORTHANDLING
  52.         UINT8     I8039_port_r(UINT8 port);
  53.         void     I8039_port_w(UINT8 port, UINT8 data);
  54.         UINT8     I8039_test_r(UINT8 port);
  55.         void     I8039_test_w(UINT8 port, UINT8 data);
  56.         UINT8     I8039_bus_r(void);
  57.         void     I8039_bus_w(UINT8 data);
  58. #else
  59.         #define  I8039_p0    0x100   /* Not used */
  60.         #define  I8039_p1    0x101
  61.         #define  I8039_p2    0x102
  62.         #define  I8039_p4    0x104
  63.         #define  I8039_p5    0x105
  64.         #define  I8039_p6    0x106
  65.         #define  I8039_p7    0x107
  66.         #define  I8039_t0    0x110
  67.         #define  I8039_t1    0x111
  68.         #define  I8039_bus    0x120
  69. #endif
  70.  
  71. /**************************************************************************
  72.  * I8035 section
  73.  **************************************************************************/
  74. #if (HAS_I8035)
  75. #define I8035_PC                I8039_PC
  76. #define I8035_SP                I8039_SP
  77. #define I8035_PSW                I8039_PSW
  78. #define I8035_A                 I8039_A
  79. #define I8035_IRQ_STATE         I8039_IRQ_STATE
  80. #define I8035_R0                I8039_R0
  81. #define I8035_R1                I8039_R1
  82. #define I8035_R2                I8039_R2
  83. #define I8035_R3                I8039_R3
  84. #define I8035_R4                I8039_R4
  85. #define I8035_R5                I8039_R5
  86. #define I8035_R6                I8039_R6
  87. #define I8035_R7                I8039_R7
  88.  
  89. #define I8035_IGNORE_INT        I8039_IGNORE_INT
  90. #define I8035_EXT_INT           I8039_EXT_INT
  91. #define I8035_TIMER_INT         I8039_TIMER_INT
  92. #define I8035_COUNT_INT         I8039_COUNT_INT
  93. #define I8035_IRQ_STATE         I8039_IRQ_STATE
  94.  
  95. #define i8035_ICount            i8039_ICount
  96.  
  97. extern void i8035_reset(void *param);
  98. extern void i8035_exit(void);
  99. extern int i8035_execute(int cycles);
  100. extern unsigned i8035_get_context(void *dst);
  101. extern void i8035_set_context(void *src);
  102. extern unsigned i8035_get_pc(void);
  103. extern void i8035_set_pc(unsigned val);
  104. extern unsigned i8035_get_sp(void);
  105. extern void i8035_set_sp(unsigned val);
  106. extern unsigned i8035_get_reg(int regnum);
  107. extern void i8035_set_reg(int regnum, unsigned val);
  108. extern void i8035_set_nmi_line(int state);
  109. extern void i8035_set_irq_line(int irqline, int state);
  110. extern void i8035_set_irq_callback(int (*callback)(int irqline));
  111. extern const char *i8035_info(void *context, int regnum);
  112. extern unsigned i8035_dasm(char *buffer, unsigned pc);
  113. #endif
  114.  
  115. /**************************************************************************
  116.  * I8048 section
  117.  **************************************************************************/
  118. #if (HAS_I8048)
  119. #define I8048_PC                I8039_PC
  120. #define I8048_SP                I8039_SP
  121. #define I8048_PSW                I8039_PSW
  122. #define I8048_A                 I8039_A
  123. #define I8048_IRQ_STATE         I8039_IRQ_STATE
  124. #define I8048_R0                I8039_R0
  125. #define I8048_R1                I8039_R1
  126. #define I8048_R2                I8039_R2
  127. #define I8048_R3                I8039_R3
  128. #define I8048_R4                I8039_R4
  129. #define I8048_R5                I8039_R5
  130. #define I8048_R6                I8039_R6
  131. #define I8048_R7                I8039_R7
  132.  
  133. #define I8048_IGNORE_INT        I8039_IGNORE_INT
  134. #define I8048_EXT_INT           I8039_EXT_INT
  135. #define I8048_TIMER_INT         I8039_TIMER_INT
  136. #define I8048_COUNT_INT         I8039_COUNT_INT
  137.  
  138. #define i8048_ICount            i8039_ICount
  139.  
  140. extern void i8048_reset(void *param);
  141. extern void i8048_exit(void);
  142. extern int i8048_execute(int cycles);
  143. extern unsigned i8048_get_context(void *dst);
  144. extern void i8048_set_context(void *src);
  145. extern unsigned i8048_get_pc(void);
  146. extern void i8048_set_pc(unsigned val);
  147. extern unsigned i8048_get_sp(void);
  148. extern void i8048_set_sp(unsigned val);
  149. extern unsigned i8048_get_reg(int regnum);
  150. extern void i8048_set_reg(int regnum, unsigned val);
  151. extern void i8048_set_nmi_line(int state);
  152. extern void i8048_set_irq_line(int irqline, int state);
  153. extern void i8048_set_irq_callback(int (*callback)(int irqline));
  154. const char *i8048_info(void *context, int regnum);
  155. extern unsigned i8048_dasm(char *buffer, unsigned pc);
  156. #endif
  157.  
  158. /**************************************************************************
  159.  * N7751 section
  160.  **************************************************************************/
  161. #if (HAS_N7751)
  162. #define N7751_PC                I8039_PC
  163. #define N7751_SP                I8039_SP
  164. #define N7751_PSW                I8039_PSW
  165. #define N7751_A                 I8039_A
  166. #define N7751_IRQ_STATE         I8039_IRQ_STATE
  167. #define N7751_R0                I8039_R0
  168. #define N7751_R1                I8039_R1
  169. #define N7751_R2                I8039_R2
  170. #define N7751_R3                I8039_R3
  171. #define N7751_R4                I8039_R4
  172. #define N7751_R5                I8039_R5
  173. #define N7751_R6                I8039_R6
  174. #define N7751_R7                I8039_R7
  175.  
  176. #define N7751_IGNORE_INT        I8039_IGNORE_INT
  177. #define N7751_EXT_INT           I8039_EXT_INT
  178. #define N7751_TIMER_INT         I8039_TIMER_INT
  179. #define N7751_COUNT_INT         I8039_COUNT_INT
  180.  
  181. #define n7751_ICount            i8039_ICount
  182.  
  183. extern void n7751_reset(void *param);
  184. extern void n7751_exit(void);
  185. extern int n7751_execute(int cycles);
  186. extern unsigned n7751_get_context(void *dst);
  187. extern void n7751_set_context(void *src);
  188. extern unsigned n7751_get_pc(void);
  189. extern void n7751_set_pc(unsigned val);
  190. extern unsigned n7751_get_sp(void);
  191. extern void n7751_set_sp(unsigned val);
  192. extern unsigned n7751_get_reg(int regnum);
  193. extern void n7751_set_reg(int regnum, unsigned val);
  194. extern void n7751_set_nmi_line(int state);
  195. extern void n7751_set_irq_line(int irqline, int state);
  196. extern void n7751_set_irq_callback(int (*callback)(int irqline));
  197. extern const char *n7751_info(void *context, int regnum);
  198. extern unsigned n7751_dasm(char *buffer, unsigned pc);
  199. #endif
  200.  
  201. #include "memory.h"
  202.  
  203. /*
  204.  *     Input a UINT8 from given I/O port
  205.  */
  206. #define I8039_In(Port) ((UINT8)cpu_readport(Port))
  207.  
  208.  
  209. /*
  210.  *     Output a UINT8 to given I/O port
  211.  */
  212. #define I8039_Out(Port,Value) (cpu_writeport(Port,Value))
  213.  
  214.  
  215. /*
  216.  *     Read a UINT8 from given memory location
  217.  */
  218. #define I8039_RDMEM(A) ((unsigned)cpu_readmem16(A))
  219.  
  220.  
  221. /*
  222.  *     Write a UINT8 to given memory location
  223.  */
  224. #define I8039_WRMEM(A,V) (cpu_writemem16(A,V))
  225.  
  226.  
  227. /*
  228.  *   I8039_RDOP() is identical to I8039_RDMEM() except it is used for reading
  229.  *   opcodes. In case of system with memory mapped I/O, this function can be
  230.  *   used to greatly speed up emulation
  231.  */
  232. #define I8039_RDOP(A) ((unsigned)cpu_readop(A))
  233.  
  234.  
  235. /*
  236.  *   I8039_RDOP_ARG() is identical to I8039_RDOP() except it is used for reading
  237.  *   opcode arguments. This difference can be used to support systems that
  238.  *   use different encoding mechanisms for opcodes and opcode arguments
  239.  */
  240. #define I8039_RDOP_ARG(A) ((unsigned)cpu_readop_arg(A))
  241.  
  242. #ifdef  MAME_DEBUG
  243. int     Dasm8039(char *dst, unsigned pc);
  244. #endif
  245.  
  246. #endif  /* _I8039_H */
  247.